import { request } from '../request'

const c = import.meta.env.DEV ? '/energy' : SERVICE_ENERGY

export interface QualityData {
  [key: string]: any
  id: number
  batchCode: string
  materialCode: string
  materialName: string
  materialSpec: string
  productNum: number
  planBillNo: string
  planStart: string
  planEnd: string
  passNum: string
  unpassNum: string
  passRate: string
  pvPassNum: string
  pvUnpassNum: string
  pvPassRate: string
  flag: '0' | '1'
}

/** 分页查质量数据 */
export async function pageQueryQualityData(
  params: {
    pageNumber: number
    pageSize: number
    batchCode?: string
    materialCode?: string
    planStartDateStart?: string
    planStartDateEnd?: string
    planEndDateStart?: string
    planEndDateEnd?: string
  },
) {
  return request.post<{
    records: QualityData[]
    total: number
  }>(`${c}/qualityData/page`, params)
}

/** 获取实时质量数据 */
export async function getRealTimeQualityData() {
  return request.post<QualityData>(`${c}/qualityData/realTimeData`)
}
